<template>
  <div class="page">
    <!-- header -->
    <van-nav-bar
      :z-index="999"
      :fixed="true"
      left-arrow
      @click-left="onClickLeft"
      :placeholder="true"
      title="基本信息"
    ></van-nav-bar>
    <div class="app-page">
      <div class="set-cells">
        <div class="basic-grid">
          <div class="basic-avatar">
            <img :src="baseURL + user.img" alt />
            <p>{{ user.name }}</p>
          </div>
        </div>
        <van-cell-group>
          <van-cell title="用户名" :value="user.loginname" />
          <van-cell title="昵称" :value="user.username" />
          <van-cell title="姓名" :value="user.name" />
          <van-cell title="状态" :value="loginname" />
          <div class="driving-school">
            <div>驾校</div>
            <p>{{ school }}</p>
          </div>
          <!-- <van-cell title="驾校" :value="school" /> -->
          <van-cell title="总课时" :value="user.zks" />
          <van-cell title="已学课时" :value="user.yxks" />
          <van-cell title="剩余课时" :value="user.syks" />
          <van-cell title="当前进度" :value="dqjd" />
        </van-cell-group>
        <van-cell-group>
          <van-cell title="手机号" :value="user.phone" />
          <van-cell
            v-if="smrz == '未认证'"
            @click="href('/IdentityAuthentication')"
            title="实名认证"
            :value="smrz"
          />
          <van-cell v-else title="实名认证" :value="smrz" />

          <van-cell
            v-if="yhk == '未绑卡'"
            @click="href('/BankCard')"
            title="银行卡"
            :value="yhk"
          />
          <van-cell v-else title="银行卡" :value="yhk" />
          <!-- <div class="btn-group">
            <van-button type="info" round block>编辑</van-button>
          </div>-->
        </van-cell-group>
        <van-cell-group>
          <van-cell title="驾校" :value="user.jxname" />
          <van-cell title="地址" :value="user.address" />
          <van-cell title="准驾车型" :value="user.zjcx" />
          <van-cell title="班型" :value="user.bx" />
          <van-cell title="教练" :value="user.jl" />
        </van-cell-group>
      </div>
    </div>
  </div>
</template>
<script>
import { basicInformation } from "../../assets/js/api/user";
import { baseURL } from "../../assets/js/config";
export default {
  data() {
    return {
      text: "",
      user: {},
      stunum: "",
      hour: "", // 课时数
      // 报名状态
      loginname: "",
      // 驾校
      school: "",
      dqjd: "",
      smrz: "", // 实名认证
      yhk: "" //银行卡是否绑卡
    };
  },

  // 接口地址
  created() {
    let dsBridge = require("dsbridge");
    dsBridge.call("goBack", "", function() {
      history.go(-1);
    });
    this.baseURL = baseURL;
    basicInformation().then(res => {
      // console.log(res);
      this.user = res.data;
      // console.log(res.data);
      switch (this.user.bmstatus) {
        case null:
          this.loginname = "未报名";
          break;
        case "1":
          this.loginname = "报名待审核";
          break;
        case "2":
          this.loginname = "已报名";
          break;
        case "3":
          this.loginname = "科目一";
          break;
        case "4":
          this.loginname = "科目二";
          break;
        case "5":
          this.loginname = "科目三";
          break;
        case "6":
          this.loginname = "科目四";
          break;
        case "7":
          this.loginname = "已结业";
          break;
      }
      // if (this.user.bmstatus == 1) {
      //   this.loginname = "未报名";
      // } else {
      //   this.loginname = "已报名";
      // }
      if (!this.user.bmstatus == null) {
        this.school = "未报名";
      } else {
        this.school = this.user.jxname;
      }
      this.dqjd = `${this.user.dqjd}%`;
      // 实名认证
      if (
        this.user.smrz == "" ||
        this.user.smrz == undefined ||
        this.user.smrz == null ||
        this.user.smrz == "0"
      ) {
        this.smrz = "未认证";
      } else {
        this.smrz = "已认证";
      }

      // this.smrz = this.school.smrz==0?'未认证':'以认证'
      // 是否绑卡
      if (
        this.user.yhk == "" ||
        this.user.yhk == undefined ||
        this.user.yhk == null
      ) {
        this.yhk = "未绑卡";
      } else {
        // this.yhk = this.user.yhk;
        this.yhk =
          res.data.yhk.substr(0, 4) + "********" + res.data.yhk.substr(-4);
      }
      //
    });
  },

  methods: {
    href(url) {
      this.$router.push({ path: url });
    },
    onClickLeft() {
      this.$router.go(-1); //返回上一层
    }
  }
};
</script>
<style scoped>
.app-page {
  background-color: #f5f5f5;
}

.set-cells .van-cell-group {
  margin-bottom: 15px;
}
</style>
